package com.augn.controller;

import com.augn.entity.Address;
import com.augn.entity.Result;
import com.augn.entity.Address;
import com.augn.service.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Iterator;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author augn
 * @since 2022-09-22
 */
@RestController
@RequestMapping("/address")
public class AddressController {

    @Autowired
    private IAddressService service;

    @PostMapping("/insertOne")
    public Result<?> insertOneAddress(@RequestBody Address address){
        return service.insertOneAddress(address);
    }

    @DeleteMapping("/deleteOne/{id}")
    public Result<?> deleteOneAddress(@PathVariable Integer id){
        return service.deleteOneAddress(id);
    }

    @PutMapping("/updateOne")
    public Result<?> updateOneAddress(@RequestBody Address address){
        return service.updateOneAddress(address);
    }

    @GetMapping("/getOne/{id}")
    public Result<?> getOneAddress(@PathVariable Integer id){
        return service.getOneAddress(id);
    }

    @GetMapping("/getPart/{id}")
    public Result<?> getPartAddress(@PathVariable Integer id){
        return service.getPartAddress(id);
    }
}
